package com.baosight.sczx.zm.ch.service;

import java.util.List;

import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.cInterface.Department;
import com.baosight.sczx.common.zm.cInterface.cp.ProducePlan;
import com.baosight.sczx.common.zm.cInterface.cs.InitialData;
import com.baosight.sczx.zm.cp.domain.ZMCPProducePlanJD;
/**
 * 
 * <p>Title: ServiceZMCHA0.java</p>
 * <p>Description: 机电运输计划验收管理  </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 郭淑芳
 * @version 1.0
 * <pre>Histroy:
 *          2016年9月30日 上午10:07:58  郭淑芳  Create
 *</pre>
 */
public class ServiceZMCHA0 extends ServiceEPBase {
	/**
	 * 
	 * <p>Function: initLoad</p>
	 * <p>Description: 初始化进入方法</p>
	 * <p>return value: ServiceZMCHA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2016年9月30日上午10:08:08 郭淑芳
	 * </p>
	 *
	 */
	@Override
	public EiInfo initLoad(EiInfo inInfo) {
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");// 如果不加这个，翻页的统计和显示是错误的
		EiInfo outInfo = this.query(inInfo);
		outInfo.addBlock(Department.getInstance().getMiningDepts("cmes.cp.department", "orgCode", "orgName", false, UserSession.getInSessionProperty("miningCode").toString()));
		return outInfo;
	}

	/**
	 * 
	 * <p>Function: query</p>
	 * <p>Description: 查询方法</p>
	 * <p>return value: ServiceZMCHA0</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2016年9月30日上午10:08:35 郭淑芳
	 * </p>
	 *
	 */
	@SuppressWarnings("rawtypes")
	public EiInfo query(EiInfo inInfo) {

		String fdMiningId = UserSession.getInSessionProperty("miningCode").toString();
		List result = ProducePlan.getProducePlanDetails("ZMCPProducePlanJD.queryByProducePlan", fdMiningId);

		EiInfo outInfo = new EiInfo();
		outInfo.addBlock("result").setBlockMeta(new ZMCPProducePlanJD().eiMetadata);
		outInfo.getBlock("result").addRows(result);

		outInfo.addBlock(Department.getInstance().getMiningDepts("cmes.cp.department", "orgCode", "orgName", false, UserSession.getInSessionProperty("miningCode").toString()));
		outInfo.addBlock(InitialData.getInstance().getEiBlockByNo("cmes.ch.planValidateData", false));// 验收类型;

		outInfo.set("fdCreator", UserSession.getInSessionProperty("UserCname")); // 登陆人
		outInfo.set("fdDepartmentId", UserSession.getInSessionProperty("orgCode")); // 登陆部门
		return outInfo;
	}
}
